package com.zq.it.service.impl;

import java.util.List;

import javax.annotation.Resource;

import com.zq.it.dao.FileSourceDao;
import com.zq.it.pojo.FileSource;
import com.zq.it.service.FileSourceService;
import com.zq.it.service.common.BaseServiceImpl;

public class FileSourceServiceImpl extends BaseServiceImpl implements FileSourceService {

	@Resource
	private FileSourceDao fileSourceDao;

	@Override
	public List<FileSource> getAllFileSource() {
		return fileSourceDao.findAll("from com.zq.it.pojo.FileSource");
	}

	@Override
	public void addFileSource(FileSource fileSource) {
		fileSourceDao.add(fileSource);
	}

	@Override
	public void deleteFileSourceByIds(long [] ids) {
		String hql = "delete from FileSource where id in (";
		if (ids != null && ids.length > 0) {
			for (long id : ids) {
				hql += id + ",";
			}
			hql = hql.substring(0, hql.lastIndexOf(',')) + ")";
			fileSourceDao.deleteSourcesByHql(hql);
		}
	}

	@Override
	public List<FileSource> findSourcesByNumber(int number) {
		return fileSourceDao.findSourcesByNumber(number);
	}
	
}
